package com.ty.day3.home;

import java.util.Random;

/**
 * Created by IntelliJ IDEA.
 *
 * @author : txy
 * @create : 2023/11/16 17:59
 */
public class Rectangle {
    private Double width;
    private Double height;

    public Double getWidth() {
        return width;
    }

    public void setWidth(Double width) {
        this.width = width;
    }

    public Double getHeight() {
        return height;
    }

    public void setHeight(Double height) {
        this.height = height;
    }

    public Rectangle() {
    }

    public Rectangle(Double width, Double height) {
        this.width = width;
        this.height = height;
    }
    public Double perimeter(){
        return 2*(width+height);
    }
    public Double area(){
        return width*height;
    }
}
class Test{
    public static void main(String[] args) {
        Rectangle[] rectangle = new Rectangle[3];
        Random random = new Random();
        for (int i = 0; i < rectangle.length; i++) {
            rectangle[i] = new Rectangle((double) random.nextInt(100), (double) random.nextInt(100));
            System.out.print("第"+(i+1)+"个长方形 长："+rectangle[i].getHeight()+"宽："+rectangle[i].getWidth());
            System.out.println("  周长："+rectangle[i].perimeter()+",面积："+rectangle[i].area());
        }
    }
}
